export function getRoomListLog (options) {
  return window.fetch({
    method: 'POST',
    url: '/roomlog/list',
    data: {
      pageNo: options.pageNo || 1,
      pageSize: options.pageSize || 10,
      startDate: options.startDate,
      targetSupplierId: options.targetSupplierId || null,
      saleHotelId: options.saleHotelId || null,
      saleRoomId: options.saleRoomId || null,
      type: options.type,
      start: options.start || null,
      end: options.end || null,
      operator: options.operator || null
    }
  })
}

export function getSaleHotelNames (options) {
  return window.fetch({
    method: 'POST',
    url: '/salehotel/names',
    data: {
      pageNum: options.HotelCurrentPage || 1,
      pageSize: options.HotelPageSize || 16,
      city: options.city || null,
      searchKey: options.searchKey || null
    }
  })
}

export function getProductQuery (options) {
  return window.fetch({
    method: 'POST',
    url: '/product/query',
    data: options
  })
}

export function getSuppliersNameList (options) {
  return window.fetch({
    method: 'POST',
    url: '/suppliers/nameList',
    data: {
      saleHotelId: options.saleHotelId || null
    }
  })
}

export function updateProduct (room, options) {
  return window.fetch({
    method: 'POST',
    url: '/product/update',
    data: Object.assign({}, room, {
      pageSize: options.limitDays,
      startDate: options.startDate,
      targetSupplierId: options.supplierId
    })
  })
}

export function getSaleRoomAllRooms (statics, sale, options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/allrooms',
    data: {
      staticRoomIds: statics || null,
      saleRoomIds: sale || null,
      saleHotelId: options.saleHotelId || null,
      supplierId: options.supplierId || null
    }
  })
}

export function getSuperior () {
  return window.fetch({
    method: 'POST',
    url: '/suppliers/getSuperior'
  })
}

export function getChannels () {
  return window.fetch({
    method: 'POST',
    url: '/suppliers/channels'
  })
}

export function getBedList (options) {
  return window.fetch({
    method: 'POST',
    url: '/bed/list',
    data: {
      saleHotelId: options.saleHotelId || null
    }
  })
}

export function updateSalerules (room, options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/salerules/update',
    data: Object.assign({}, room, {
      pageSize: options.limitDays,
      startDate: options.startDate,
      targetSupplierId: options.supplierId
    })
  })
}

export function getloadItens (options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/loadItems',
    data: {
      id: options.saleHotelId
    }
  })
}

export function addSaleRoom (room, options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/add',
    data: Object.assign({}, room, {
      pageSize: options.limitDays,
      startDate: options.startDate,
      targetSupplierId: options.supplierId
    })
  })
}

export function updateSaleRoom (room, options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/update',
    data: Object.assign({}, room, {
      targetSupplierId: options.supplierId
    })
  })
}

export function updateRoomStatus (room, options) {
  return window.fetch({
    method: 'POST',
    url: '/roomstatus/update',
    data: Object.assign({}, room, {
      pageSize: options.limitDays,
      startDate: options.startDate,
      targetSupplierId: options.supplierId
    })
  })
}

export function getMinimalList (statics, sale, options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/minimalList',
    data: {
      staticRoomIds: statics,
      saleRoomIds: sale,
      saleHotelId: options.saleHotelId,
      supplierId: options.supplierId || null
    }
  })
}

export function updateRoomPrices (room, options) {
  return window.fetch({
    method: 'POST',
    url: '/roomPrices/update',
    data: {
      saleRoomPrices: room,
      pageSize: options.limitDays,
      saleHotelId: options.saleHotelId,
      startDate: options.startDate,
      targetSupplierId: options.supplierId
    }
  })
}

export function shareProduct (statics, sale, supplier, options) {
  return window.fetch({
    method: 'POST',
    url: '/product/share',
    data: {
      staticRoomIds: statics,
      saleRoomIds: sale,
      supplierId: supplier,
      saleHotelId: options.saleHotelId,
      pageSize: options.limitDays,
      startDate: options.startDate,
      targetSupplierId: options.supplierId
    }
  })
}

export function saleRoomToggle (status, id, options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/online/toggle',
    data: {
      status: status,
      id: id,
      pageSize: options.limitDays,
      targetSupplierId: options.supplierId
    }
  })
}

export function deleteSaleRoom (options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/online/toggle',
    data: options
  })
}

export function getDateProduct (options, mode) {
  return window.$http({
    method: 'GET',
    url: '/product/getdate',
    params: {
      token: window.commo.token,
      inDate: options.startDate,
      mode: mode
    }
  })
}

export function getSaleRoom (options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/get',
    data: {
      id: options
    }
  })
}

export function editSaleRoom (room, options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/update',
    data: {
      saleRoomBaseInfo: {
        bedTypeId: room.bedTypeId || null,
        breakfast: room.breakfast,
        cancelDesc: room.cancelDesc || null,
        cancelHours: room.cancelHours || null,
        cancelMinutes: room.cancelMinutes || null,
        cancelRule: room.cancelRule,
        id: room.id || null,
        name: room.name || null,
        peopleNum: room.peopleNum || 0,
        purchasePrice: room.purchasePrice || null,
        supplierId: room.supplierId || null
      },
      pageSize: options.limitDays || null,
      targetSupplierId: options.supplierId || null
    }
  })
}

export function getSaleRoomList (options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/room/list',
    data: options
  })
}

export function addStaticRoom (room, options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/staticroom/add',
    data: Object.assign({}, room, {
      pageSize: options.limitDays,
      startDate: options.startDate,
      targetSupplierId: options.supplierId
    })
  })
}

export function updateInventory (room, options) {
  return window.fetch({
    method: 'POST',
    url: '/inventory/update',
    data: Object.assign({}, room, {
      pageSize: options.limitDays,
      startDate: options.startDate,
      targetSupplierId: options.supplierId
    })
  })
}

export function updateBacthInventory (room, edit, options) {
  return window.fetch({
    method: 'POST',
    url: '/inventory/update',
    data: Object.assign({}, room, edit, {
      pageSize: options.limitDays,
      startDate: options.startDate,
      targetSupplierId: options.supplierId
    })
  })
}

export function getAllRooms (room, statics, options) {
  return window.fetch({
    method: 'POST',
    url: '/saleroom/allrooms',
    data: Object.assign({}, room, {
      staticRoomIds: statics.staticRoom || null,
      saleRoomIds: statics.saleRoom || null,
      saleHotelId: options.saleHotelId || null,
      supplierId: options.supplierId || null
    })
  })
}

export function showPrice () {
  return window.fetch({
    method: 'GET',
    url: '/product/purchaseprice/show',
    params: {
      token: window.commo.token
    }
  })
}
